/********************************************************************
	
	Tau Virtual Machine
	
	tau_types.h
	
	Copyright (c) 2009 Tau Virtual Machine Project
	
	See COPYING.txt for copying and redistribution conditions.
	
	Author:  Matt C.
	Date:  Aug 07, 2009
	
********************************************************************/

#ifndef TAU_TYPES_H
#define TAU_TYPES_H

// STRUCTURES *******************************************************

typedef struct _TauValue		TauValue;

typedef struct _TauComplex		TauComplex;
typedef struct _TauString		TauString;
typedef struct _TauArray		TauArray;
typedef struct _TauHash			TauHash;
typedef struct _TauMatrix		TauMatrix;
typedef struct _TauObject		TauObject;
typedef struct _TauRoutine		TauRoutine;

struct _TauValue
{
	int type;
	int refs;
	
	union
	{
		int i;
		int b;
		double r;
		TauComplex* c;
		TauString* s;
		TauObject* o;
		TauRoutine* R;
	} data;
};

//TauArray* a;
//TauHash* h;
//TauMatrix* m;

struct _TauComplex
{
	double real;
	double imag;
};

struct _TauString
{
	char* data;
	int len;
};

struct _TauObject
{
	TauValue* data;
	// properties, attributes, features?
};

struct _TauRoutine
{
	unsigned int len;
	unsigned char* code;
	
	unsigned short nparams;
	char** params;				// Only for debugging
	
	unsigned short nlocals;		// nlocals includes nparams
	char** locals;				// Only for debugging
	
	unsigned short nroutines;
	TauRoutine* routines;
};

/*
struct _TauArray
{
	TauObject data;
	int capacity;
	int len;
};

struct _TauHash
{
	
	int len;
};
*/

TauValue* TauMakeValue		(void);

TauValue* TauMakeNull		(void);
TauValue* TauMakeInteger	(int i);
TauValue* TauMakeBoolean	(int b);
TauValue* TauMakeReal		(double r);
TauValue* TauMakeComplex	(double cr, double ci);
TauValue* TauMakeString		(void);

TauValue* TauIntegerNegate			(TauValue* vs, TauValue* vt);
TauValue* TauIntegerAdd				(TauValue* vs, TauValue* vt);
TauValue* TauIntegerSubtract		(TauValue* vs, TauValue* vt);
TauValue* TauIntegerMultiply		(TauValue* vs, TauValue* vt);
TauValue* TauIntegerDivide			(TauValue* vs, TauValue* vt);
TauValue* TauIntegerModulo			(TauValue* vs, TauValue* vt);
TauValue* TauIntegerFloorDivide		(TauValue* vs, TauValue* vt);
TauValue* TauIntegerBitNot			(TauValue* vs, TauValue* vt);
TauValue* TauIntegerAnd				(TauValue* vs, TauValue* vt);
TauValue* TauIntegerOr				(TauValue* vs, TauValue* vt);
TauValue* TauIntegerXor				(TauValue* vs, TauValue* vt);
TauValue* TauIntegerNot				(TauValue* vs, TauValue* vt);
TauValue* TauIntegerEqual			(TauValue* vs, TauValue* vt);
TauValue* TauIntegerNotEqual		(TauValue* vs, TauValue* vt);
TauValue* TauIntegerGreater			(TauValue* vs, TauValue* vt);
TauValue* TauIntegerLess			(TauValue* vs, TauValue* vt);
TauValue* TauIntegerGreaterEqual	(TauValue* vs, TauValue* vt);
TauValue* TauIntegerLessEqual		(TauValue* vs, TauValue* vt);

TauValue* TauBooleanNegate			(TauValue* vs, TauValue* vt);
TauValue* TauBooleanAdd				(TauValue* vs, TauValue* vt);
TauValue* TauBooleanSubtract		(TauValue* vs, TauValue* vt);
TauValue* TauBooleanMultiply		(TauValue* vs, TauValue* vt);
TauValue* TauBooleanDivide			(TauValue* vs, TauValue* vt);
TauValue* TauBooleanModulo			(TauValue* vs, TauValue* vt);
TauValue* TauBooleanFloorDivide		(TauValue* vs, TauValue* vt);
TauValue* TauBooleanBitNot			(TauValue* vs, TauValue* vt);
TauValue* TauBooleanAnd				(TauValue* vs, TauValue* vt);
TauValue* TauBooleanOr				(TauValue* vs, TauValue* vt);
TauValue* TauBooleanXor				(TauValue* vs, TauValue* vt);
TauValue* TauBooleanNot				(TauValue* vs, TauValue* vt);
TauValue* TauBooleanEqual			(TauValue* vs, TauValue* vt);
TauValue* TauBooleanNotEqual		(TauValue* vs, TauValue* vt);
TauValue* TauBooleanGreater			(TauValue* vs, TauValue* vt);
TauValue* TauBooleanLess			(TauValue* vs, TauValue* vt);
TauValue* TauBooleanGreaterEqual	(TauValue* vs, TauValue* vt);
TauValue* TauBooleanLessEqual		(TauValue* vs, TauValue* vt);

TauValue* TauRealNegate				(TauValue* vs, TauValue* vt);
TauValue* TauRealAdd				(TauValue* vs, TauValue* vt);
TauValue* TauRealSubtract			(TauValue* vs, TauValue* vt);
TauValue* TauRealMultiply			(TauValue* vs, TauValue* vt);
TauValue* TauRealDivide				(TauValue* vs, TauValue* vt);
TauValue* TauRealModulo				(TauValue* vs, TauValue* vt);
TauValue* TauRealFloorDivide		(TauValue* vs, TauValue* vt);
TauValue* TauRealBitNot				(TauValue* vs, TauValue* vt);
TauValue* TauRealAnd				(TauValue* vs, TauValue* vt);
TauValue* TauRealOr					(TauValue* vs, TauValue* vt);
TauValue* TauRealXor				(TauValue* vs, TauValue* vt);
TauValue* TauRealNot				(TauValue* vs, TauValue* vt);
TauValue* TauRealEqual				(TauValue* vs, TauValue* vt);
TauValue* TauRealNotEqual			(TauValue* vs, TauValue* vt);
TauValue* TauRealGreater			(TauValue* vs, TauValue* vt);
TauValue* TauRealLess				(TauValue* vs, TauValue* vt);
TauValue* TauRealGreaterEqual		(TauValue* vs, TauValue* vt);
TauValue* TauRealLessEqual			(TauValue* vs, TauValue* vt);

TauValue* TauComplexNegate			(TauValue* vs, TauValue* vt);
TauValue* TauComplexAdd				(TauValue* vs, TauValue* vt);
TauValue* TauComplexSubtract		(TauValue* vs, TauValue* vt);
TauValue* TauComplexMultiply		(TauValue* vs, TauValue* vt);
TauValue* TauComplexDivide			(TauValue* vs, TauValue* vt);
TauValue* TauComplexModulo			(TauValue* vs, TauValue* vt);
TauValue* TauComplexFloorDivide		(TauValue* vs, TauValue* vt);
TauValue* TauComplexBitNot			(TauValue* vs, TauValue* vt);
TauValue* TauComplexAnd				(TauValue* vs, TauValue* vt);
TauValue* TauComplexOr				(TauValue* vs, TauValue* vt);
TauValue* TauComplexXor				(TauValue* vs, TauValue* vt);
TauValue* TauComplexNot				(TauValue* vs, TauValue* vt);
TauValue* TauComplexEqual			(TauValue* vs, TauValue* vt);
TauValue* TauComplexNotEqual		(TauValue* vs, TauValue* vt);
TauValue* TauComplexGreater			(TauValue* vs, TauValue* vt);
TauValue* TauComplexLess			(TauValue* vs, TauValue* vt);
TauValue* TauComplexGreaterEqual	(TauValue* vs, TauValue* vt);
TauValue* TauComplexLessEqual		(TauValue* vs, TauValue* vt);

TauValue* TauStringNegate			(TauValue* vs, TauValue* vt);
TauValue* TauStringAdd				(TauValue* vs, TauValue* vt);
TauValue* TauStringSubtract			(TauValue* vs, TauValue* vt);
TauValue* TauStringMultiply			(TauValue* vs, TauValue* vt);
TauValue* TauStringDivide			(TauValue* vs, TauValue* vt);
TauValue* TauStringModulo			(TauValue* vs, TauValue* vt);
TauValue* TauStringFloorDivide		(TauValue* vs, TauValue* vt);
TauValue* TauStringBitNot			(TauValue* vs, TauValue* vt);
TauValue* TauStringAnd				(TauValue* vs, TauValue* vt);
TauValue* TauStringOr				(TauValue* vs, TauValue* vt);
TauValue* TauStringXor				(TauValue* vs, TauValue* vt);
TauValue* TauStringNot				(TauValue* vs, TauValue* vt);
TauValue* TauStringEqual			(TauValue* vs, TauValue* vt);
TauValue* TauStringNotEqual			(TauValue* vs, TauValue* vt);
TauValue* TauStringGreater			(TauValue* vs, TauValue* vt);
TauValue* TauStringLess				(TauValue* vs, TauValue* vt);
TauValue* TauStringGreaterEqual		(TauValue* vs, TauValue* vt);
TauValue* TauStringLessEqual		(TauValue* vs, TauValue* vt);

// END **************************************************************

#endif

